<!--客户端登录-->
<template>

  <div style="background-color: white; width: 700px;height: 300px; margin: 100px auto; padding: 50px; border-radius: 10px">

    <div  >
      <el-container>
        <el-aside width="300px">
          <img  src="../../public/images/login-img.png">
        </el-aside>
        <el-main>
          <div style="height: 350px">
            <h1 style="text-align: center; margin: 0 0 30px 0">防疫酒店管控系统</h1>
            <h6 style="text-align: center; margin: 0 0 30px 0">Welcome欢迎登陆</h6>

            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
              <el-form-item style="text-align: left" label="账号:" prop="username">
                <el-input v-model="ruleForm.username"></el-input>

              </el-form-item>
              <el-form-item style="text-align: left" label="密码:" prop="password">
                <el-input v-model="ruleForm.password"></el-input>
              </el-form-item>

              <el-form-item id="button">
                <el-button type="primary" @click="submitForm('ruleForm')" style="background-color: #00aaff">登录</el-button>
                <el-button   @click="open" style="color: white;background-color: #00aaff;width: 95px">二维码登录</el-button>
                <el-button @click="registered()" style="color: white;background-color: #00aaff">注册</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-main>
      </el-container>
      <div>
        <el-dialog
            :visible.sync="imgvisible"
            title="二维码登录">
          <div style="height: 500px;text-align: center">
            <img src="../../public/images/login-img.png">
          </div>
        </el-dialog>
      </div>
    </div>
  </div>

</template>

<script>
export default {
  data() {
    return {
      imgvisible:false,
      ruleForm: {

        username: '',
        password: ''
      },
      rules: {
        username: [
          {required: true, message: '请输入用户名', trigger: 'blur'},
          {min: 4, max: 15, message: '长度在 4 到 15 个字符', trigger: 'blur'}
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
          {min: 6, max: 12, message: '长度在 6 到 12 个字符', trigger: 'blur'}
        ]
      }
    };
  },
  methods: {
    open(){
      this.imgvisible=true;
    },
    submitForm(formName) {
      // 检查表单是否通过验证
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('登录成功');
        } else {
          console.log('登录失败');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    registered(){
      this.$router.push('/Register');
    }
  }
}
</script>

<style>
 body{
  background: url("../../public/images/bg.jpg") ;
  background-repeat: no-repeat;
  background-size: 110% 110% ;
}



img{
  width: 300px;
  height: 300px;
  margin: 0 auto;
  padding: 0;
}
#button{

}

</style>